<template>
  <div>
    <div>
      <van-field
        v-model="message"
        maxlength="50"
        rows="1"
        label="评论"
        type="textarea"
        show-word-limit
        placeholder="请输入留言"
      >
        <template #button>
          <van-button @click="clickdiscuss" size="small" type="primary">评论</van-button>
        </template>
      </van-field>
    </div>
    <div v-for="(item,index) in discussArr" :key="index">
      <van-divider>{{item.name}}说：</van-divider>
      <div>{{item.content}}</div>
    </div>
  </div>
</template>

<script>
import { mapActions, mapState } from "vuex";
export default {
  props: ["bdid"],
  data() {
    return {
      message: ""
    };
  },
  mounted() {
    this.getDisList({ bdid: this.bdid });
  },
  computed: {
    ...mapState({
      discussArr: state => state.msbd.discussArr
    })
  },
  methods: {
    ...mapActions("msbd", ["getDisList", "saveDis"]),
    async clickdiscuss() {
      let obj = {};
      obj.content = this.message;
      obj.bdid = this.bdid;
      obj.uid = 1;
      // this.saveDis(obj).then(res=>{
      //   this.getDisList({ bdid: this.bdid })
      // });
     await this.saveDis(obj)
     this.message=''
     this.getDisList({ bdid: this.bdid })
    }
  }
};
</script>

<style lang="scss" scoped>
</style>